home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-20 / rs0422.zip / LEVEL1 / HDWINT.AS < prev    next >
Text File  |  1990-11-14  |  3KB  |  202 lines

  1. *TITLE    HDWINT - 'Hardware init and linking module'
  2.  
  3. ;  HDWINT performs the necessary system initialization.
  4. ;  The SIO interrupt service routine entry points are
  5. ;  also here so that the SIO data structure for the
  6. ;  interrupting channel can be external to the SIO
  7. ;  driver (HDLSIO).  This allows that module to be
  8. ;  generic.
  9.  
  10. *INCLUDE RCONFIG.LIB
  11. *INCLUDE STRUCT.LIB
  12.  
  13. ;  External routine declaration
  14.  
  15.     GLOBAL    HDWINT, IPAGE
  16.     GLOBAL    XSKED        ;HDLSIO callable subs
  17.     GLOBAL    I_TBE,I_RBF,I_EXT,I_SRX    ;HDLSIO interrupt subs
  18.     GLOBAL    SPRINTC
  19.  
  20.     PSECT    bss
  21. SPRINTC: DEFS 1
  22.     PSECT    text
  23.  
  24. *HEADING 'Initialization Subroutine'
  25.  
  26. ;  Initialize the interrupt vector page
  27.  
  28. HDWINT:
  29.     LD    HL,IPAGE    ;Base of vectors
  30.     LD    DE,SPRINT    ;Spurious handler
  31.     LD    B,128        ;Number of vectors
  32. ILOOP:    LD    (HL),E        ;Set vector to SPRINT
  33.     INC    HL
  34.     LD    (HL),D
  35.     INC    HL
  36.     DJNZ    ILOOP
  37.  
  38. ;  Initialize the CPU interrupt logic and set the vectors
  39.  
  40.     LD    DE,IPAGE    ;Set the vectors
  41.     LD    HL,IV
  42.     LD    BC,IVL
  43.     LD    A,D        ;Set the I register
  44.     LD    I,A
  45.     LDIR
  46.     IM    2        ;Interrupt mode 2
  47.  
  48.     JP    0004h        ;Configure Low level Hardware
  49.  
  50. *HEADING 'Interrupt Service Routines'
  51.  
  52. ;  SPRINT - Spurious interrupt service
  53. ;  A deadly condition requires a drastic cure.
  54.  
  55. SPRINT:
  56.     RETI
  57. ;    HALT            ;Die, you old bastard
  58.  
  59. ;  SIO interrupt service entries
  60.  
  61. I_TBE0:
  62.     PUSH    IY
  63.     LD    IY,SDS0
  64.     JR    TBE
  65. I_RBF0:
  66.     PUSH    IY
  67.     LD    IY,SDS0
  68.     JP    RBF
  69. I_EXT0:
  70.     PUSH    IY
  71.     LD    IY,SDS0
  72.     JP    EXT
  73. I_SRX0:
  74.     PUSH    IY
  75.     LD    IY,SDS0
  76.     JP    SRX
  77.  
  78.     COND    NUMCH .gt. 1
  79. I_TBE1:
  80.     PUSH    IY
  81.     LD    IY,SDS1
  82.     JR    TBE
  83. I_RBF1:
  84.     PUSH    IY
  85.     LD    IY,SDS1
  86.     JP    RBF
  87. I_EXT1:
  88.     PUSH    IY
  89.     LD    IY,SDS1
  90.     JP    EXT
  91. I_SRX1:
  92.     PUSH    IY
  93.     LD    IY,SDS1
  94.     JP    SRX
  95.  
  96.     ENDC
  97.     COND    NUMCH .gt. 2
  98. I_TBE2:
  99.     PUSH    IY
  100.     LD    IY,SDS2
  101.     JR    TBE
  102. I_RBF2:
  103.     PUSH    IY
  104.     LD    IY,SDS2
  105.     JP    RBF
  106. I_EXT2:
  107.     PUSH    IY
  108.     LD    IY,SDS2
  109.     JP    EXT
  110. I_SRX2:
  111.     PUSH    IY
  112.     LD    IY,SDS2
  113.     JP    SRX
  114.  
  115.     ENDC
  116.     COND    NUMCH .gt. 3
  117. I_TBE3:
  118.     PUSH    IY
  119.     LD    IY,SDS3
  120.     JR    TBE
  121. I_RBF3:
  122.     PUSH    IY
  123.     LD    IY,SDS3
  124.     JP    RBF
  125. I_EXT3:
  126.     PUSH    IY
  127.     LD    IY,SDS3
  128.     JP    EXT
  129. I_SRX3:
  130.     PUSH    IY
  131.     LD    IY,SDS3
  132.     JP    SRX
  133.     ENDC
  134. TBE:
  135.     EXX
  136.     LD    HL,I_TBE
  137.     JR    SERVICE
  138. RBF:
  139.     EXX
  140.     LD    HL,I_RBF
  141.     JR    SERVICE
  142. SRX:
  143.     EXX
  144.     LD    HL,I_SRX
  145.     JR    SERVICE
  146. EXT:
  147.      EXX
  148.     LD    HL,I_EXT
  149. ;    JR    SERVICE        ;This gets called the most.
  150.  
  151. SERVICE:
  152.     PUSH    AF        ;Hi-Tech Divide routines use AF and AF'
  153.     PUSH    IX
  154.     CALL    VECTOR
  155.     LD    C,(IY+CPORT)    ;;
  156.     LD    A,38H        ;;
  157.     OUT    (C),A        ;;DR200 IGNORES RETI??
  158.     POP    IX
  159.     POP    AF
  160.     EXX
  161.     POP    IY
  162.     EI
  163.     RETI
  164.  
  165. VECTOR:
  166.     JP    (HL)        ;Vector to subroutine
  167.  
  168. *HEADING 'SIO Data Structures'
  169.  
  170.     PSECT    bss
  171.     GLOBAL    SDS0
  172. SDS0:    DEFS    SDSLEN
  173.  
  174.     COND    NUMCH .gt. 1
  175.     GLOBAL    SDS1
  176. SDS1:    DEFS    SDSLEN
  177.     ENDC
  178.  
  179.     COND    NUMCH .gt. 2
  180.     GLOBAL    SDS2
  181. SDS2:    DEFS    SDSLEN
  182.     ENDC
  183.  
  184.     COND    NUMCH .gt. 3
  185.     GLOBAL    SDS3
  186. SDS3:    DEFS    SDSLEN
  187.     ENDC
  188.  
  189. ;  Interrupt vectors
  190.  
  191.     psect    data
  192. IV:
  193.     DEFW    I_TBE1,I_EXT1,I_RBF1,I_SRX1
  194.     DEFW    I_TBE0,I_EXT0,I_RBF0,I_SRX0
  195.     COND    NUMCH .gt. 2
  196.     DEFW    I_TBE3,I_EXT3,I_RBF3,I_SRX3
  197.     DEFW    I_TBE2,I_EXT2,I_RBF2,I_SRX2
  198.     ENDC
  199. IVL    EQU    $-IV
  200.  
  201.     END
  202.